package com.iyundao.io.mapper;

import com.iyundao.io.model.Gift;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

public class GiftSqlProvider {

    public String insertSelective(Gift record) {
        BEGIN();
        INSERT_INTO("gift");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getGiftname() != null) {
            VALUES("giftname", "#{giftname,jdbcType=VARCHAR}");
        }
        
        if (record.getGiftnum() != null) {
            VALUES("giftnum", "#{giftnum,jdbcType=VARCHAR}");
        }
        
        if (record.getGiftintegral() != null) {
            VALUES("giftintegral", "#{giftintegral,jdbcType=INTEGER}");
        }
        
        if (record.getGiftdetails() != null) {
            VALUES("giftdetails", "#{giftdetails,jdbcType=VARCHAR}");
        }
        
        if (record.getGiftimg() != null) {
            VALUES("giftimg", "#{giftimg,jdbcType=VARCHAR}");
        }
        
        if (record.getGifttime() != null) {
            VALUES("gifttime", "#{gifttime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getGiftflag() != null) {
            VALUES("giftflag", "#{giftflag,jdbcType=SMALLINT}");
        }
        
        if (record.getOrganizationid() != null) {
            VALUES("organizationid", "#{organizationid,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateSelective(Gift record) {

        String s = null;

        if (record.getGiftname() != null) {
            s += "giftname=" + record.getGiftname();
        }

        if (record.getGiftnum() != null) {
           s += "giftnum=" + record.getGiftnum();
        }

        if (record.getGiftintegral() != null) {
            s += "giftintegral=" + record.getGiftintegral();
        }

        if (record.getGiftdetails() != null) {
            s += "giftdetails=" + record.getGiftdetails();
        }

        if (record.getGiftimg() != null) {
           s += "giftimg=" + record.getGiftimg();
        }

        if (record.getGifttime() != null) {
           s += "gifttime=" + record.getGifttime();
        }

        if (record.getGiftflag() != null) {
            s += "giftflag=" + record.getGiftflag();
        }

        if (record.getOrganizationid() != null) {
            s += "organizationid=" + record.getOrganizationid();
        }
        BEGIN();
        UPDATE("gift");
        SET(s);
        WHERE("id=#{id,jdbcType=INTEGER}");

        return SQL();
    }
}